feat(worktree): add automatic cleanup and workspace manager - #1841
Merged
bobleer merged 2 commits intoJul 29, 2026
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Type and Areas
Type:
Feature / UI/UX / reliability / test
Areas:
Rust core, Agent Runtime, desktop/Tauri, web UI, i18n
Motivation / Impact
Managed worktrees can accumulate and consume disk space, while users previously had no central place to inspect or remove them. This adds conservative automatic cleanup after worktree creation and a settings-based management surface.
The catalog now reflects BitFun-owned storage instead of displaying every worktree registered with the same Git repository. Its rows use a compact workspace header, branch and path hierarchy, one-line conversation summary, and icon deletion action so large worktree sets remain scannable.
Manual and automatic deletion intentionally use different policies. A user can explicitly remove a checkout even when conversations reference it; those conversations remain in history, but the deleted checkout is no longer available. Automatic cleanup remains non-destructive and skips any worktree with associated conversations, local changes, unpublished commits, Git locks, missing directories, or non-managed lifecycle policies. New worktrees also receive a 24-hour grace period.
The Agent integration makes the worktree execution target explicit to the parent Agent and ensures fresh Task subagents persist under the owning project with the same execution target.
Verification
cargo check --workspacecargo test -p bitfun-agent-runtime— all tests passedcargo test -p bitfun-core service::worktree::tests::— 18 passedcargo test -p bitfun-core fresh_subagent_inherits_matching_parent_worktree_bindingcargo test -p bitfun-core workspace_context_identifies_the_managed_worktree_bindingcargo test -p bitfun-core-types worktree -- --nocapture— 4 passedcargo test -p bitfun-desktop remote_workspace_policy -- --nocapture— 5 passedpnpm run type-check:webpnpm run lint:webpnpm --dir src/web-ui run test:run src/infrastructure/config/components/WorktreesConfig.test.tsx— 4 passedpnpm run i18n:audit— 0 warningsnode scripts/check-core-boundaries.mjspnpm run theme:color-audit:allpnpm run fmt:rsReviewer Notes
app.worktrees.rootPath; the desktop command remainsLocalOnlyfor remote-workspace policy.Checklist